package com.kun.portal.webframe.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.kun.portal.webframe.util.Loaded;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by Administrator on 2018-09-06.
 * 进程节点
 *
 */
@Entity
@Table(
        name = "fbo_course_nodes"
)
@JsonSerialize
public class CourseNodePo implements Serializable {
    @Id
    @GeneratedValue(
            generator = "node_id"
    )

    @GenericGenerator(
            name = "node_id",
            strategy = "uuid"
    )
    @Column(
            name = "node_id",
            length = 32,
            nullable = false
    )
    private String nodeId;//id
    @Column(
            name = "node_name",
            length = 32,
            nullable = true
    )
    private String nodeName;//节点名称
    @Column(
            name = "node_state",
            length = 32,
            nullable = true
    )
    private String nodeState;//节点状态
    @Column(
            name = "sec_unit",
            length = 32,
            nullable = true
    )
    private String secUnit;//保障单位


    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "plane_id", referencedColumnName = "plane_id")
    @JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class,property="@plane_id")
    private FlightPlanePo flightPlanePo;

    @Column(
            name = "node_time",
            nullable = true
    )

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
    @Temporal(TemporalType.TIMESTAMP)
    private Date nodeTime;//节点时间

    @Column(
            name = "enter_time",
            nullable = true
    )
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
    @Temporal(TemporalType.TIMESTAMP)
    private Date enterTime;//节点时间
    @Column(
            name = "data_sources",
            length = 32,
            nullable = true
    )
    private String dataSources;//数据来源

    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", referencedColumnName = "user_id",insertable = true,updatable = true)
    private FwUserPo dataEntryClerk;

    public String getNodeId() {
        return nodeId;
    }

    public void setNodeId(String nodeId) {
        this.nodeId = nodeId;
    }

    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public String getNodeState() {
        return nodeState;
    }

    public void setNodeState(String nodeState) {
        this.nodeState = nodeState;
    }

    public String getSecUnit() {
        return secUnit;
    }

    public void setSecUnit(String secUnit) {
        this.secUnit = secUnit;
    }

    public Date getNodeTime() {
        return nodeTime;
    }

    public void setNodeTime(Date nodeTime) {
        this.nodeTime = nodeTime;
    }

    public String getDataSources() {
        return dataSources;
    }

    public void setDataSources(String dataSources) {
        this.dataSources = dataSources;
    }

    public FwUserPo getDataEntryClerk() {
        return (FwUserPo) Loaded.loaded(dataEntryClerk);
    }

    public void setDataEntryClerk(FwUserPo dataEntryClerk) {
        this.dataEntryClerk = dataEntryClerk;
    }

    public FlightPlanePo getFlightPlanePo() {
        return (FlightPlanePo) Loaded.loaded(flightPlanePo);
    }

    public void setFlightPlanePo(FlightPlanePo flightPlanePo) {
        this.flightPlanePo = flightPlanePo;
    }

    public Date getEnterTime() {
        return enterTime;
    }

    public void setEnterTime(Date enterTime) {
        this.enterTime = enterTime;
    }
}
